Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render ligatures #1510

Closed
wants to merge 1 commit into from
Closed

Render ligatures #1510

wants to merge 1 commit into from

Conversation

mattblagden
Copy link

Enable ligature rendering via the text-rendering style, and account for a client-rect bug in Chromium that resulted in improper editing cursor placement.

The proper fix for this is to get the latest version of Chromium, where the client-rect bug has been fixed. I'm just submitting this pull request in case anyone wants the change in the meantime.

(Hackily) Fixes #192


The editor gets a bad rectangle from the DOM when the editing cursor is at the end of the line. Specifically, requesting the coordinates of the right side of the the last character yields an incorrect value.

With just the CSS to enable ligatures, the cursor renders in an incorrect position whenever it's at the end of a line (regardless of whether ligatures are present):
broken demo

The bad-rectangle issue has been fixed in Chromium, so only the CSS change is necessary once VS Code uses newer Chromium.

In the meantime, the problem can be avoided by detecting requests for a point at the end of the line and using the bounding-box of the entire element to compute the correct value (i.e. instead of trying to get the right side of the last character inside the element, just get the right side of the entire element).

With the the ligature CSS and the bounding-box workaround, the caret renders in the correct position (and ligatures are rendered):
ligature demo

Enable ligature rendering via the text-rendering style, and account for a client-rect bug in chromium that resulted in improper cursor placement.
@msftclas
Copy link

Hi @mattblagden, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!
We will now validate the agreement and then real humans will evaluate your PR.

TTYL, MSBOT;

@jrappen
Copy link

jrappen commented Dec 23, 2015

Could you disable them for lines with cursors in them?

Compare the Editing paragraph on https://medium.com/@larsenwork/ligatures-coding-fonts-5375ab47ef8e as well as these settings for the Atom editor:

* {
  -webkit-font-smoothing: antialiased;
  -webkit-font-feature-settings: "liga" on, "calt" on;
}

atom-text-editor::shadow .cursor-line {
  -webkit-font-feature-settings: "liga" off, "calt" off;
}

div.find-and-replace atom-text-editor::shadow .line {
  -webkit-font-feature-settings: "liga" off, "calt" off;
}

@mattblagden
Copy link
Author

@jrappen You could, but there's also a fix that makes them render correctly whether it's the current line or not; it's detailed in the discussion of the original issue (#192).

@jrappen
Copy link

jrappen commented Dec 24, 2015

@mattblagden thanks for the info, appreciated!

@alexdima alexdima modified the milestones: Jan 2016, Backlog Jan 5, 2016
@alexdima
Copy link
Member

@mattblagden Thank you for the PR, I used it as a great inspiration source for bcd90ac, which adds this under an editor configuration option. It is behind an option due to my concerns of this affecting other cases we support (see #192 (comment))

@RobertPaulson90
Copy link

RobertPaulson90 commented Jul 25, 2017

Hello @alexandrudima @mattblagden. If interested, please check #30925. Seems relevant for you guys

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for font ligatures
6 participants